thin.imports('/public/configure/conf.pwd.js');

thin.use(function() {
	// 頁面加載完畢
	// thin.effect();

	thin.imports('/public/webfe/resource/sms.js');

	$('#submit-forgot').on('click', function() {
		verifySMSCode(submitForgot);
	});
});

var __getdata_pwdreset;

function submitForgot() {
	var data_opt = {
		'mobile': $('[layout-mark=sms-mobile]').val(),
		'password': $('#ipt-fg-password').val(),
		'confpwd': $('#ipt-fg-confpwd').val()
	};
	if(data_opt.mobile == '') {
		layer.msg('请输入手机号', {
			icon: 2,
			time: 800
		});
		return;
	} else if(data_opt.password == '') {
		layer.msg('请输入密码', {
			icon: 2,
			time: 800
		});
		return;
	} else if(data_opt.confpwd != data_opt.password) {
		layer.msg('两次密码输入不正确', {
			icon: 2,
			time: 800
		});
		return;
	}
	layer.load(0, {
		shade: [0.08, '#000']
	});
	__getdata_pwdreset = data_opt;
	factory.request('_member_pwdreset');
}

function __complete_pwdreset(res) {
	layer.closeAll('loading');
	if(res.status == 201) {
		layer.msg('修改成功');
		setTimeout(function() {
			window.location.href = '/member/login.html';
		}, 1200);
	} else {
		layer.msg(res.error, {
			icon: 2,
			time: 800
		});
	}
}
